package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.Reservation;
import com.zzyl.vo.ReservationVo;
import com.zzyl.vo.TimeCountVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface CostomerReservationMapper {
    //统计取消人数
    List<TimeCountVo> countReservationsForEachTimeWithinTimeRange(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
    //
    int countCancelledReservationsWithinTimeRange(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("updateBy") Long updateBy);
//添加预约
    void insert(Reservation reservation);
//分页查询
    Page<ReservationVo> getByPage(Integer pageNum, Integer pageSize, Integer status);
//取消预约
    @Update("update reservation set status=2 where id=#{id}")
    void cancel(@Param("id") Long id);
//时间段内取消的次数
    @Select("SELECT  COUNT(*)  FROM reservation WHERE name = #{name} AND status = 2 ;")
    int countReservation(String name);
}
